import { api } from '../api';

// 获取训练营信息，接收一个 sentence 参数
export const getCampMeta = async (sentence: string) => {
  try {
    // 传递 sentence 参数到 GET 请求中
    const response = await api.get("/java/teacher/StudySpaceTeacher/getTrainingCampList", {
      params: { sentence }, // 将 sentence 参数添加到请求参数中
    });
    return response.data;
  }
  catch (error) {
    console.error("训练营列表请求失败:", error);
    throw new Error("训练营列表请求失败");
  }
};
// 获取对应训练营课程信息，接收一个 sentence 参数
export const getCourseMeta = async (coursesTag: string) => {
  try {
    // 传递 sentence 参数到 GET 请求中
    const response = await api.get("/java/teacher/StudySpaceTeacher/getCourseReview", {
      params: { coursesTag }, // 将 sentence 参数添加到请求参数中
    });
    return response.data;
  }
  catch (error) {
    console.error("课程列表请求失败:", error);
    throw new Error("课程列表请求失败");
  }
};

// 查看某个训练营作业提交情况
export const getHomeworkSubmitStatus = async (studentId: string, camp: string) => {
  try {
    // 传递 sentence 参数到 GET 请求中
    const response = await api.get("/java/ground/camp_app/homework", {
      params: { studentId, camp },
    });
    return response.data;
  }
  catch (error) {
    console.error("作业完成情况获取请求失败:", error);
    throw new Error("作业完成情况获取请求失败");
  }
};

// 获取结营证书（）
export const getCertification = async (templateId: string, name: string) => {
  try {
    // 传递 sentence 参数到 GET 请求中
    const response = await api.get("/java/user/certificate/get", {
      params: { templateId, name },
    });
    return response.data;
  }
  catch (error) {
    console.error("证书获取请求失败:", error);
    throw new Error("证书获取请求失败");
  }
};
